Inside Macintosh: Sound

| Previous | Chapter contents | Chapter top | Section top | Next |

Opening and Closing the Apple Mixer Component

A sound output device component needs to open and close one or more instances of the Apple Mixer component.

OpenMixerSoundComponent

A sound output device component can use the OpenMixerSoundComponent function to open and connect itself to the Apple Mixer component.

pascal OSErr OpenMixerSoundComponent
                                                              (SoundComponentDataPtr
                     outputDescription,
                                                              long outputFlags,
                                                              ComponentInstance
                     *mixerComponent);
outputDescription
A description of the data format your sound output device is expecting to receive.
outputFlags
A set of 32 bit flags that provide additional information about the data format your output device is expecting to receive. See "Data Format Flags" for a description of the constants you can use to select bits in this parameter.
mixerComponent
The component instance of the Apple Mixer component. You need this instance to call the SoundComponentGetSourceData and CloseMixerSoundComponent functions.

DESCRIPTION

The OpenMixerSoundComponent function opens the standard Apple Mixer component and creates a connection between your sound output device component and the Apple Mixer. If your output device can perform specific operations on the stream of audio data, such as channel mixing and rate conversion, it should call OpenMixerSoundComponent as many times as are necessary to create a unique component chain for each sound source. If, on the other hand, your output device does not perform channel mixing, it should call OpenMixerSoundComponent only once, from its SoundComponentInitOutputDevice function. This opens a single instance of the Apple Mixer component, which in turn manages all the available sound sources.

Your component specifies the format of the data it can handle by filling in a sound component data record and passing its address in the outputDescription parameter. The sound component data record specifies the data format as well as the sample rate and sample size expected by the output device component. If these specifications are sufficient to determine the kind of data your component can handle, you should pass the value 0 in the outputFlags parameter. Otherwise, you can set flags in the outputFlags parameter to select certain kinds of input data. For example, you can set the kNoChannelConversion flag to prevent the component chain from converting monophonic sound to stereo sound, or stereo sound to monophonic sound. See "Data Format Flags" for a description of the constants you can use to select bits in the outputFlags parameter.

SPECIAL CONSIDERATIONS

The OpenMixerSoundComponent function is available only in versions 3.0 and later of the Sound Manager. It should be called only by sound output device components.

CloseMixerSoundComponent

A sound output device component can use the CloseMixerSoundComponent function to close the Apple Mixer.

pascal OSErr CloseMixerSoundComponent (ComponentInstance ci);
ci
The component instance of the Apple Mixer component.

DESCRIPTION

The CloseMixerSoundComponent function closes the Apple Mixer component instance specified by the ci parameter. Your output device component should call this function when it is being closed.

SPECIAL CONSIDERATIONS

The CloseMixerSoundComponent function is available only in versions 3.0 and later of the Sound Manager. It should be called only by sound output device components.

RESULT CODES

noErr

0

No error

invalidComponentID

-3000

Invalid component ID


© 1998 Apple Computer, Inc.

| Previous | Chapter contents | Chapter top | Section top | Next |